/*
 * ReadWriteLock.cpp
 *
 *  Created on: 13.12.2012
 *      Author: zheka
 */

#include "ReadWriteLock.hpp"

ReadWriteLock::ReadWriteLock() {
//	pthread_rwlockattr_t attr;
//	pthread_rwlockattr_init(&attr);
//	pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
	pthread_rwlock_init(&rwlock, NULL);
//
//	pthread_rwlockattr_destroy(&attr);
//	pthread_mutex_init(&mutex, NULL);
}
ReadWriteLock::~ReadWriteLock() {
	pthread_rwlock_destroy(&rwlock);
//	pthread_mutex_destroy(&mutex);
}
void ReadWriteLock::readLock() {
	pthread_rwlock_rdlock(&rwlock);
//	pthread_mutex_lock(&mutex);
}
void ReadWriteLock::writeLock() {
	pthread_rwlock_wrlock(&rwlock);
//	pthread_mutex_lock(&mutex);
}
void ReadWriteLock::unlock() {
	pthread_rwlock_unlock(&rwlock);
//	pthread_mutex_unlock(&mutex);
}
